package ModelLayer;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;

import com.example.genericrpg_android.R;

public class Menu {
	List<String> options;
	private int size, index;
	private MediaPlayer scrollClip;
	private MediaPlayer pressClip;
	private boolean selecting = false;
	
	public Menu(String[] op, Context activity){
		// add all the elements
		options = new ArrayList<String>();
		size = op.length;
		for(int i=0; i<size; i++){
			options.add(op[i]);
		}
		index = 0; 
		
		scrollClip = MediaPlayer.create(activity, R.raw.menumove);
		pressClip = MediaPlayer.create(activity, R.raw.menuselect);
//		scrollClip.setLooping(false);
//		pressClip.setLooping(false);

	}
	
	public Menu(ArrayList<String> op, Context activity) {
		options = op;
		size = options.size();
		index = 0;

		scrollClip = MediaPlayer.create(activity, R.raw.menumove);
		pressClip = MediaPlayer.create(activity, R.raw.menuselect);
		scrollClip.setLooping(false);
		pressClip.setLooping(false);
	}

	public ArrayList<String> getOptions() {
		// TODO Auto-generated method stub
		return (ArrayList<String>) options;
	}

	public void nextOption() {
		if(index<size-1)
			index++;
		System.out.println("\t"+options.get(index));
		scrollClip.start();
	}

	public String getOption() {
		// TODO Auto-generated method stub
		return options.get(index);
	}
	
	public void select(){
		pressClip.start();
		selecting = true;
	}
	
	public boolean isSelected(){
		return selecting;
	}
	
	public void reset(){
		selecting = false;
	}

	public void previousOption() {
		if (index>0)
			index--;
		System.out.println("\t"+options.get(index));
		scrollClip.start();
	}
	
	public void setOption(int index) {
		this.index = index;
	}
}
